package com.andrew.Controller;

import com.andrew.pojo.Address;
import com.andrew.pojo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ResponseController {
    @RequestMapping("/hello")
    public Result hello() {
        System.out.println("hello");
//        return new Result(1, "success", "hello world");
        return Result.success("hello world");
    }

    @RequestMapping("/getAddr")
    public Result getAddr() {
        Address addr = new Address();
        addr.setProvince("广东");
        addr.setCity("肇庆");
        return Result.success(addr);
    }

    @RequestMapping("/listAddr")
    public Result listAddr() {
        List<Address> list = new ArrayList<>();

        Address addr = new Address();
        addr.setProvince("广东");
        addr.setCity("肇庆");
        Address addr2 = new Address();
        addr2.setProvince("江西");
        addr2.setCity("南昌");
        list.add(addr);
        list.add(addr2);
        return Result.success(list);
    }
}
